package com.yiwyn;

import com.yiwyn.domain.User;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.command.Command;
import org.kie.api.runtime.ExecutionResults;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.StatelessKieSession;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class Main {


    public static void main(String[] args) {
        KieServices kieServices = KieServices.Factory.get();
        KieContainer kieContainer = kieServices.getKieClasspathContainer();

        KieSession kSession = kieContainer.newKieSession("ksession-rule");

        String  s = "sender != \"BOBANK\" && sender != \"\" ";

        Command abc = kieServices.getCommands().newAgendaGroupSetFocus("abc");
        List<Command> cmds = new ArrayList<>();
        cmds.add(abc);
        User user = new User("", new BigDecimal("1.12"));
        cmds.add(kieServices.getCommands().newInsert(user, "user"));

//        kSession.getAgenda().getAgendaGroup("abc").setFocus();

        ExecutionResults execute = kSession.execute(kieServices.getCommands().newBatchExecution(cmds));
        System.out.println(execute.toString());
//
        kSession.fireAllRules();
        kSession.dispose();
    }


}